package web.servlet.list.web;

import web.servlet.list.dao.UserDao;
import web.servlet.list.dao.UserDaoImpl;
import web.servlet.list.domin.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @Author Administrator
 * @Date 2020/6/12 9:17
 **/
@WebServlet("/userListServlet")
public class UserListServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    this.doGet(request, response);
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        UserDao dao=new UserDaoImpl();
        List<User> userList = dao.findAll();
        request.setAttribute("userList",userList);
        request.getRequestDispatcher("/list/list.jsp").forward(request,response);
    }
}
